<template>
  <div>
    <button @click="go()">MaterialView</button>
    <button @click="go2()">MaterialUser</button>
    <ElForm style="width: 300px">
      <ElFormItem label="请假类型">
        <ElSelect v-model="leaveBill.leaveType">
          <ElOption value="sick" label="病假"></ElOption>
          <ElOption value="annual" label="年假"></ElOption>
          <ElOption value="issue" label="事假"></ElOption>
        </ElSelect>
      </ElFormItem>
      <ElFormItem label="开始时间">
        <ElDatePicker v-model="leaveBill.timeStart"></ElDatePicker>
      </ElFormItem>
      <ElFormItem label="结束时间">
        <ElDatePicker v-model="leaveBill.timeEnd"></ElDatePicker>
      </ElFormItem>
      <ElFormItem label="请假原因">
        <ElInput v-model="leaveBill.reason"></ElInput>
      </ElFormItem>
      <ElButton @click="insert()">新增</ElButton>
    </ElForm>
  </div>
</template>
<script lang="ts">
/**
 * 页面核心数据结构体说明文档
 *
 *
 */
// import from

export default {
  name: 'MaterialView',
  props: {
    sampleP: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      sampleD: 'value',
      leaveBill: {
        leaveType: 'annual',
        timeStart: '2023-06-03T07:07:10.211Z',
        timeEnd: '2023-06-06T07:07:10.211Z',
        reason: '休养生息'
      }
    }
  },
  computed: {
    /* sampleC() {
      return this.sampleD + "--";
    }, */
  },
  // 当开启了keepalive缓存后，切换页面时 created 和mounted等
  // 生命周期函数不会运行，因为没有生成新的实例
  // 此时能自动运行的函数是activated函数，代表窗口被重新激活
  created() {
    console.log("儿童时期")
  },
  mounted() {
    console.log("青年时期")
  },
  activated(){
    console.log("返回登场")
  },
  methods: {
    // sampleM() {},
    async go() {
      const res = await axios({
        method: 'post',
        url: 'http://localhost:7001/account/query/1'
      })
      console.log(res.data)
    },
    async go2() {
      const res = await axios({
        method: 'get',
        url: 'http://localhost:7001/api/get_user'
      })
      console.log(res.data)
    },
    async insert() {
      const res = await axios({
        method: 'post',
        url: 'http://localhost:7001/leave/insert',
        data: this.leaveBill
      })
      console.log(res.data)
    }
  },
  watch: {
    // sampleP(n, o) {},
  }
}
</script>

<!--<style scoped>-->
<style lang="scss" scoped></style>
